banner

SNAP - 06: If, else branches in context

OPENING QUESTIONS:

Senseis: Write a program that:

  • accepts two separate numbers (assume they will be integers)
  • states whether each of those numbers are positive or negative (You will need to use the 'modulus' operator. Please do a wee bit of research on how to do that)
  • determines whether the product of those numbers (multiplication) and the quotient of those numbers (division) are both positive, both negative or one of each (you MUST use Boolean logic here -- And/Or

Rookies: Please write a brief program that asks the user to:

  • Type in 2 separate boolean values (True or False, Yes or No)

  • Select a boolean operator (And or Or)

  • Create a branch statement (If/else) to process that input so that the two values input by the user are compared using AND or OR

  • Output the result to your user

OBJECTIVE:   I will be able to write a real-world program to evaluate input from a user after today's class.

WORD FOR TODAY:

  • Boolean (true or false, yes or no, on or off, 1 or 0)
  • Mod operator (The mod or 'modulus' operator returns the remainder when one number is divided by another. For example: 5 mod 2 evaluates 5/2 which equals 2 with a remainder of 1. There for the output of that expression is the remainder which is 1

WORK O' THE DAY

Let's take about 20 minutes to work on the opener and see how we're doing